//
//  S1mpl3DiscoveryCollectionViewCell.m
//  沙哈拉FM
//
//  Created by dllo on 15/11/4.
//  Copyright © 2015年 S1mpl3. All rights reserved.
//
#import "FitHeader.h"
#import "S1mpl3DiscoveryCollectionViewCell.h"
#import "UIImageView+WebCache.h"
#import "Model.h"


@implementation S1mpl3DiscoveryCollectionViewCell


-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
        [self changeColor];
    }
    return self;
}

-(void)changeColor{
    self.backgroundColor = [Model shareInstance].ViewColor;
}

- (void)createView{
    _coverPathImageView = [[UIImageView alloc]init];
    //    _coverPathImageView.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:_coverPathImageView];
    
    _titleTopLabel = [[BaseLabel alloc]init];
    [_titleTopLabel setFontSize:18];
    //    _titleTopLabel.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:_titleTopLabel];
    
    _titleBottomLabel = [[BaseLabel alloc]init];
    [_titleBottomLabel setFontSize:14];
    _titleBottomLabel.textColor = [UIColor lightGrayColor];
    //    _titleBottomLabel.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:_titleBottomLabel];
}

- (void)layoutSubviews{
    [super layoutSubviews];
    _coverPathImageView.frame = CGRectMake(10 * FITWidth, 0, 100 * FITWidth, 100 * FITHeight);
    _titleTopLabel.frame = CGRectMake(_coverPathImageView.frame.origin.x + _coverPathImageView.frame.size.width + 10 * FITWidth, _coverPathImageView.frame.origin.y, self.contentView.frame.size.width - _coverPathImageView.frame.size.width - 20 * FITWidth, 30 * FITHeight);

    _titleBottomLabel.frame = CGRectMake(_titleTopLabel.frame.origin.x, _titleTopLabel.frame.origin.y + _titleTopLabel.frame.size.height + 5 * FITHeight, _titleTopLabel.frame.size.width, 30 * FITHeight);
}

-(void)setDiscovery:(Discovery *)discovery{
    [_coverPathImageView sd_setImageWithURL:[NSURL URLWithString:discovery.coverPath] placeholderImage:[UIImage imageNamed:@"200*200"]];
    _titleTopLabel.text = discovery.title;
    _titleBottomLabel.text = discovery.subtitle;
    [self changeColor];
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
